I was beginning to feel like Harry Potter and The Mirror of Erised (see end of post for reference). I was getting wasted away before it. DBE frame2 = frame(box, "Frame 2") frame2->"top"->"flush"->frame1; frame2->"left"->"form"; frame2->"right"->"form"; frame2->"bottom"->"aligned"->frame1; For the first frame I had to toss in an anchor to grab onto at the top and do this for the very first:
DBE topSep = separator(box); topSep->"top"->"form"; topSep->"left"->"form"; topSep->"right"->"form"; topSep->"bottom"->"unattached"; DBE frame1 = frame(box, "Frame 1") frame1->"top"->"form"; frame1->"left"->"form"; frame1->"right"->"form"; frame1->"bottom"->"aligned"->topSep;
DB box;
DBE ceiling;
DBE frames[10];
DBE labels[50];
int frameIndex = -1;
int labelIndex = -1;
void addFrame() {
frameIndex++;
if (frameIndex == sizeof(frames)) {
ack("increase frames array size!");
destroy(box);
halt();
}
frames[frameIndex] = frame(box, "Frame " (frameIndex) "");
if (frameIndex == 0) {
frames[frameIndex]->"top"->"form";
frames[frameIndex]->"bottom"->"aligned"->ceiling;
} else {
frames[frameIndex]->"top"->"flush"->frames[frameIndex-1];
frames[frameIndex]->"bottom"->"aligned"->frames[frameIndex-1];
}
frames[frameIndex]->"left"->"form";
frames[frameIndex]->"right"->"form";
}
void addLabelsToFrame(int howMany) {
int i;
for (i = 0; i < howMany; i++) {
labelIndex++;
if (labelIndex == sizeof(labels)) {
ack("increase labels array size!");
destroy(box);
halt();
}
labels[labelIndex] = label(box, "Label " (labelIndex) "");
if (i == 0) {
labels[labelIndex]->"top"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"top"->"flush"->labels[labelIndex-1];
}
labels[labelIndex]->"left"->"inside"->frames[frameIndex];
labels[labelIndex]->"right"->"inside"->frames[frameIndex];
if (i == (howMany - 1)) {
labels[labelIndex]->"bottom"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"bottom"->"unattached";
}
}
}
void simpleFrame() {
void closeDialog(DB box) {
hide(box);
destroy(box);
//ack("Bye");
}
box = create("My Dialog");
ceiling = separator(box);
ceiling->"top"->"form";
ceiling->"left"->"form";
ceiling->"right"->"form";
ceiling->"bottom"->"unattached";
addFrame();
addLabelsToFrame(3);
addFrame();
addLabelsToFrame(1);
addFrame();
addLabelsToFrame(20);
// Don't want an auto-populated close button
close(box, false, closeDialog);
hide(ceiling);
realize(box);
show(box);
}
simpleFrame();
SystemAdmin - Wed Nov 30 16:37:09 EST 2011 |
Re: Frames auto-sizing -- Solved! |
Re: Frames auto-sizing -- Solved! llandale - Thu Dec 01 15:42:14 EST 2011
As I was integrating frame stuff into what I was working on, I found it broke something else. (as usual!) Packing the frames with the Bottom Aligned stunt will prohibit vertical growth. But I think I found a reasonable work-around.
DB box;
DBE ceiling;
DBE frames[10];
DBE labels[50];
int frameIndex = -1;
int labelIndex = -1;
void addFrame() {
frameIndex++;
if (frameIndex == sizeof(frames)) {
ack("increase frames array size!");
destroy(box);
halt();
}
frames[frameIndex] = frame(box, "Frame " (frameIndex) "");
if (frameIndex == 0) {
frames[frameIndex]->"top"->"form";
} else {
frames[frameIndex]->"top"->"flush"->frames[frameIndex-1];
}
frames[frameIndex]->"left"->"form";
frames[frameIndex]->"right"->"form";
}
//------------------------------------------------------------------------------
// DOORS default frame sizes seem to be about 5 text lines tall. I don't know
// of any means to set the size.
//------------------------------------------------------------------------------
// Adding 5 or more lines?:
// The the default is fine. The frame will grow bigger if you add more.
//---
// Adding less than 5 lines and want to pack tightly vertically and don't mind
// if it can't be vertically stretched?:
// Call this routine.
// Side effect -- You can not enable dynamic growth with setExtraHeightShare.
// The frame will remain packed tightly.
//---
// Adding less than 5 lines and want to pack tightly vertically and want to
// the frame to participate in vertical dialog box stretching?:
// You are out of luck (left as an exercise for the reader.)
//------------------------------------------------------------------------------
void verticalPackFrame(int index) {
if (index == 0) {
frames[index]->"bottom"->"aligned"->ceiling;
} else {
frames[index]->"bottom"->"aligned"->frames[index-1];
}
}
void addLabelsToFrame(int howMany) {
int i;
for (i = 0; i < howMany; i++) {
labelIndex++;
if (labelIndex == sizeof(labels)) {
ack("increase labels array size!");
destroy(box);
halt();
}
labels[labelIndex] = label(box, "Label " (labelIndex) "");
if (i == 0) {
labels[labelIndex]->"top"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"top"->"flush"->labels[labelIndex-1];
}
labels[labelIndex]->"left"->"inside"->frames[frameIndex];
labels[labelIndex]->"right"->"inside"->frames[frameIndex];
if (i == (howMany - 1)) {
labels[labelIndex]->"bottom"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"bottom"->"unattached";
}
}
}
void addButtonsToFrame() {
void buttonDialog(DBE someButton) {
ack("Button pressed")
}
DBE button1 = button(box, "Button 1", buttonDialog);
DBE button2 = button(box, "Button 2", buttonDialog);
DBE button3 = button(box, "Button 3", buttonDialog);
button1->"top"->"inside"->frames[frameIndex];
button1->"left"->"inside"->frames[frameIndex];
button1->"right"->"unattached";
button1->"bottom"->"inside"->frames[frameIndex];
button2->"top"->"inside"->frames[frameIndex];
button2->"left"->"spaced"->button1;
button2->"right"->"unattached";
button2->"bottom"->"inside"->frames[frameIndex];
button3->"top"->"inside"->frames[frameIndex];
button3->"left"->"spaced"->button2;
button3->"right"->"inside"->frames[frameIndex];
button3->"bottom"->"inside"->frames[frameIndex];
}
void simpleFrame() {
void closeDialog(DB box) {
hide(box);
destroy(box);
}
box = create("My Dialog");
// Don't want an auto-populated close button
close(box, false, closeDialog);
ceiling = separator(box);
ceiling->"top"->"form";
ceiling->"left"->"form";
ceiling->"right"->"form";
ceiling->"bottom"->"unattached";
addFrame();
addLabelsToFrame(1);
addFrame();
addLabelsToFrame(1);
addFrame();
addLabelsToFrame(1);
addFrame();
addButtonsToFrame();
// pack frames 0, 3 (This can't grow if dialog gets stretched)
verticalPackFrame(0);
verticalPackFrame(3);
hide(ceiling);
realize(box);
// frames 1 and 2 will share vertical growth
// equally if dialog box gets stretched
setExtraHeightShare(frames[1], 0.5);
setExtraHeightShare(frames[2], 0.5);
show(box);
}
simpleFrame();
|
Re: Frames auto-sizing -- Solved! SystemAdmin - Thu Dec 01 16:08:04 EST 2011
As I was integrating frame stuff into what I was working on, I found it broke something else. (as usual!) Packing the frames with the Bottom Aligned stunt will prohibit vertical growth. But I think I found a reasonable work-around.
DB box;
DBE ceiling;
DBE frames[10];
DBE labels[50];
int frameIndex = -1;
int labelIndex = -1;
void addFrame() {
frameIndex++;
if (frameIndex == sizeof(frames)) {
ack("increase frames array size!");
destroy(box);
halt();
}
frames[frameIndex] = frame(box, "Frame " (frameIndex) "");
if (frameIndex == 0) {
frames[frameIndex]->"top"->"form";
} else {
frames[frameIndex]->"top"->"flush"->frames[frameIndex-1];
}
frames[frameIndex]->"left"->"form";
frames[frameIndex]->"right"->"form";
}
//------------------------------------------------------------------------------
// DOORS default frame sizes seem to be about 5 text lines tall. I don't know
// of any means to set the size.
//------------------------------------------------------------------------------
// Adding 5 or more lines?:
// The the default is fine. The frame will grow bigger if you add more.
//---
// Adding less than 5 lines and want to pack tightly vertically and don't mind
// if it can't be vertically stretched?:
// Call this routine.
// Side effect -- You can not enable dynamic growth with setExtraHeightShare.
// The frame will remain packed tightly.
//---
// Adding less than 5 lines and want to pack tightly vertically and want to
// the frame to participate in vertical dialog box stretching?:
// You are out of luck (left as an exercise for the reader.)
//------------------------------------------------------------------------------
void verticalPackFrame(int index) {
if (index == 0) {
frames[index]->"bottom"->"aligned"->ceiling;
} else {
frames[index]->"bottom"->"aligned"->frames[index-1];
}
}
void addLabelsToFrame(int howMany) {
int i;
for (i = 0; i < howMany; i++) {
labelIndex++;
if (labelIndex == sizeof(labels)) {
ack("increase labels array size!");
destroy(box);
halt();
}
labels[labelIndex] = label(box, "Label " (labelIndex) "");
if (i == 0) {
labels[labelIndex]->"top"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"top"->"flush"->labels[labelIndex-1];
}
labels[labelIndex]->"left"->"inside"->frames[frameIndex];
labels[labelIndex]->"right"->"inside"->frames[frameIndex];
if (i == (howMany - 1)) {
labels[labelIndex]->"bottom"->"inside"->frames[frameIndex];
} else {
labels[labelIndex]->"bottom"->"unattached";
}
}
}
void addButtonsToFrame() {
void buttonDialog(DBE someButton) {
ack("Button pressed")
}
DBE button1 = button(box, "Button 1", buttonDialog);
DBE button2 = button(box, "Button 2", buttonDialog);
DBE button3 = button(box, "Button 3", buttonDialog);
button1->"top"->"inside"->frames[frameIndex];
button1->"left"->"inside"->frames[frameIndex];
button1->"right"->"unattached";
button1->"bottom"->"inside"->frames[frameIndex];
button2->"top"->"inside"->frames[frameIndex];
button2->"left"->"spaced"->button1;
button2->"right"->"unattached";
button2->"bottom"->"inside"->frames[frameIndex];
button3->"top"->"inside"->frames[frameIndex];
button3->"left"->"spaced"->button2;
button3->"right"->"inside"->frames[frameIndex];
button3->"bottom"->"inside"->frames[frameIndex];
}
void simpleFrame() {
void closeDialog(DB box) {
hide(box);
destroy(box);
}
box = create("My Dialog");
// Don't want an auto-populated close button
close(box, false, closeDialog);
ceiling = separator(box);
ceiling->"top"->"form";
ceiling->"left"->"form";
ceiling->"right"->"form";
ceiling->"bottom"->"unattached";
addFrame();
addLabelsToFrame(1);
addFrame();
addLabelsToFrame(1);
addFrame();
addLabelsToFrame(1);
addFrame();
addButtonsToFrame();
// pack frames 0, 3 (This can't grow if dialog gets stretched)
verticalPackFrame(0);
verticalPackFrame(3);
hide(ceiling);
realize(box);
// frames 1 and 2 will share vertical growth
// equally if dialog box gets stretched
setExtraHeightShare(frames[1], 0.5);
setExtraHeightShare(frames[2], 0.5);
show(box);
}
simpleFrame();
But wait! If you create the frame with width and height of 1, and use bottom unattached, then setExtraHeightShare seems to work and ballance is restored in the universe. frames[frameIndex] = frame(box, "Frame " (frameIndex) "", 1, 1) -Louie Don't tease me with "left as an exercise" again! |
Re: Frames auto-sizing -- Solved! llandale - Thu Dec 01 17:12:19 EST 2011
But wait! If you create the frame with width and height of 1, and use bottom unattached, then setExtraHeightShare seems to work and ballance is restored in the universe. frames[frameIndex] = frame(box, "Frame " (frameIndex) "", 1, 1) -Louie Don't tease me with "left as an exercise" again!
Louie, thanks! I never though I'd be quoting Niccolo Machiavelli, but it seems with DXL "The end justifies the means".
frame
Declaration
DBE frame(DB box,
string label
[,int width,
int height])
Operation Creates a frame element in box, which can contain other elements. The label is the title of the frame; width and height specify the size of the frame in pixels. If width and height are omitted, the frame expands to fit the elements within it.
// This starts out as a deflated balloon and expands to added content. frames[frameIndex] = frame(box, "Frame " (frameIndex) "", 1, 1);
|
Re: Frames auto-sizing -- Solved! SystemAdmin - Fri Dec 02 12:26:01 EST 2011
Louie, thanks! I never though I'd be quoting Niccolo Machiavelli, but it seems with DXL "The end justifies the means".
frame
Declaration
DBE frame(DB box,
string label
[,int width,
int height])
Operation Creates a frame element in box, which can contain other elements. The label is the title of the frame; width and height specify the size of the frame in pixels. If width and height are omitted, the frame expands to fit the elements within it.
// This starts out as a deflated balloon and expands to added content. frames[frameIndex] = frame(box, "Frame " (frameIndex) "", 1, 1);
The paragraphs in the DXL manual are "clues" not "rules". It doesn't matter if that statement is really true, it's useful. At least on Fridays. These DXL statements are technically correct. They do expand to fit when you omit the size; only implying that it doesn't when you do. The 2nd sentance should, but need not, include phrase "the initial size", and the 3rd sentance should insert phrase "the frame starts with a minimum size and". The section on "contrained placement" should better explain what those commands do vis-a-vis individual DBEs; but that's impossible since nobody really knows due to the numerous <disallowed content detected> behaviors. -Louie ... who just this week figured out what a "dash-space" does at the beginning of a line! Are you asking me if I ever looked at my boss and decided to smash it and start again? I've been instructed not to comment on that litigation. |
Re: Frames auto-sizing -- Solved!
|
Re: Frames auto-sizing -- Solved! llandale - Mon Dec 05 12:06:24 EST 2011
Here are my assumptions about the DBE model. Most of the below is is a mix of help file descriptions and empirical behavioral observations. ANYONE -- If you know otherwise, please correct.
If anyone has crafted a "DBE explorer" to illustrate the (left, right, top, and bottom) connections among DBE objects, please share. This would be a useful debugging tool for relationships gone wrong (marital relationships out of scope!) |